﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeneratorLib;
using GeneratorLib.DB;
using GeneratorLib.DB.Connectios;
using GeneratorLib.DB.Schemas;

namespace Generator.Generators
{
    public partial class GeneratorBase : Form
    {

        public GeneratorBase()
        {
            InitializeComponent();
            this.TopLevel = false;
            tbGenerate.DropDown.Items.Clear();
        }

        public IConnection Connection { get; set; }
        private TableInfo _table;
        public TableInfo Table
        {
            get
            {
                return _table;
            }
            set
            {
                _table = value;
                tbTableName.Items.Clear();
                tbTableName.Items.Add(_table.TableName);
                tbTableName.SelectedIndex = 0;
            }
        }

        public string GeneratorName {
            get
            {
                return tbGeneratorName.Text;
            }
            set
            {
                tbGeneratorName.Text = value;
            }
        }

        public void AddToolStripItem(ToolStripItem item)
        {
            tbGenerate.DropDown.Items.Add(item);
        }

        public virtual void Generate()
        {
            if (tbGenerate.DropDown.Items.Count > 0)
            {
                Generate(tbGenerate.DropDown.Items[0]);
            }
        }

        private void tbRefresh_Click(object sender, EventArgs e)
        {
            //Generate();
        }

        private void tbRefresh_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            Generate(e.ClickedItem);
        }

        public virtual void Generate(ToolStripItem item)
        {
        }

        public virtual void Save()
        { 
        }

        private void GeneratorBase_MouseDown(object sender, MouseEventArgs e)
        {

        }


    }
}
